package com.ffs.fsm;


/**
 * 状态机测试
 *
 * @author fengfasong
 * @date 2021/4/24
 */
public class TestMain {

    public static void main(String[] args) {
        CaseEnum createRole = CaseEnum.LOGIN_ROLE;
        switch (createRole) {
            case LOGIN_ROLE:
                caseLR();
                break;
            case CREATE_ROLE_LOGIN:
                caseCRL();
                break;
            case CREATE_ROLE:
                caseCR();
                break;
            default:
                break;
        }
    }

    /**
     * 创建角色登录
     */
    private static void caseCRL() {
        FSMMachine machine = new FSMMachine();
        machine.transform(State.init, Event.InitScene, new Context("高渐离"));
        machine.transform(State.login, Event.LoginScene, new Context("高渐离"));
        machine.transform(State.select_roles, Event.SelectRoleScene, new Context("高渐离"));
    }

    /**
     * 创建角色
     */
    private static void caseCR() {
        FSMMachine machine = new FSMMachine();
        machine.transform(State.init, Event.InitScene, new Context("张良"));
        machine.transform(State.login, Event.LoginScene, new Context("张良"));
        machine.transform(State.random_name, Event.RandomNameScene, new Context("张良"));
    }

    /**
     * 登录角色
     */
    private static void caseLR() {
        FSMMachine machine = new FSMMachine();
        machine.transform(State.init, Event.InitScene, new Context("端木蓉"));
        machine.transform(State.login, Event.LoginScene, new Context("端木蓉"));
        machine.transform(State.select_roles, Event.SelectRoleScene, new Context("端木蓉"));
    }

}
